The first instance of obj whose box contains the point (x, y), or nothing.
collision_point(x, y, obj) -> ref<object>| Name | Type |
|---|---|
x | real |
y | real |
obj | object |
ref<object>
The first instance of obj whose box contains the point (x, y), or nothing - the instance-lookup equivalent of point_meeting's plain true/false, for code that wants to act on whichever instance it found rather than just know that one exists.
The point (x, y) is a place in the room, counted from the room's top-left corner.
If obj is a parent, the answer can be one of its children. With obj_enemy as the parent of obj_slime, collision_point(x, y, obj_enemy) can hand back a slime. The reference is typed as obj_enemy, so you can use the variables and events obj_enemy has through it. The parent's own instances are searched first, then each child's. An object whose Code-tab box Never moves is ticked is answered from a look-up grid instead - same answer, much less work when there are many copies (Never moves). It still hands back the same copy: the first one, in the same order.
An instance destroyed earlier in the same frame still counts for this check until the end of the frame, because instance_destroy only ends it then. The one exception is a Collision event, which skips it at once.
An instance with no sprite and no mask size has a box with no size, and a box with no size contains no point, so this never finds one. (Overlap and collision has the whole rule.)
var hit = collision_point(x, y, obj_doc_target);
if (hit != nothing) {
instance_destroy(hit);
}Checks whether the bolt's own exact point currently sits inside any obj_doc_target instance's box, and destroys the first one found - the single-point counterpart to collision_rect's rectangle.
Like collision_rect, a parent’s name covers its children, and the result is typed as obj. Same two caveats as collision_rect: the FIRST match only, and an instance destroyed earlier in this same frame is still one of them.